// 指向-计时
class model3Ren extends eui.Component{
    private gou:eui.Image;
    private btn:eui.Image;
    private isClick:boolean = false;
    public RETURN_VALUE:string = "returnValue";

    public constructor(){
        super();
        this.once(eui.UIEvent.COMPLETE,this.onComplete,this);
        this.skinName = "src/Game/gameRoom/DIYBtn/model3RenSkin.exml";
    }
    private onComplete(){
        this.once(egret.Event.REMOVED_FROM_STAGE,this.onRemove,this);
        this.btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this);
        this.updateUi();
    }
    private onClick(e:egret.TouchEvent){ 
        if(this.isClick){
            StageData.soundObj.soundSinglePlay("click");
             this.dispatchEventWith(this.RETURN_VALUE,false,false);
        }else{
             this.dispatchEventWith(this.RETURN_VALUE,false,true);
             StageData.soundObj.soundSinglePlay("isClick");
        }       
    }
    private onRemove(){
        egret.Tween.removeTweens(this.gou);
        this.btn.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this);
    }
    private updateUi(){
        if(this.isClick == false){
            this.gou.visible = false;
        }else{
            this.gou.visible = true;
            this.gou.scaleX = this.gou.scaleY = 0;
            egret.Tween.removeTweens(this.gou);
            egret.Tween.get(this.gou).to({scaleX:1,scaleY:1},200,egret.Ease.backOut);
        }
    }
    public setContent(value:boolean){
        this.isClick = value;
        this.updateUi();
    }
}